package com.useeinfo.oa.modules.wuHanCommon.base.entity;


import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.CommonSugar;
import com.useeinfo.oa.modules.base.entity.Area;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "wuhan_warning_group")
public class WarningGroup extends SuperClassEntity<WarningGroup> {

    /**
     * 报警组code
     */
    private String code;
    /**
     * 报警组名称
     */
    private String name;
    /**
     * 报修区域
     */
    @ManyToOne
    @JoinColumn(name = "area_id")
    private Area reportArea;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Area getReportArea() {
        return reportArea;
    }

    public void setReportArea(Area reportArea) {
        this.reportArea = reportArea;
    }

    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        Area area=CommonSugar.getTypedDefault(getReportArea(),new Area());

        jsonObject.put("name", CommonSugar.getTypedDefault(getName(), ""));
        jsonObject.put("code", CommonSugar.getTypedDefault(getCode(), ""));
        jsonObject.put("areaName", CommonSugar.getTypedDefault(area.getAreaName(), ""));

        return jsonObject;
    }

}
